package com.pms.mapper;

import com.github.pagehelper.Page;
import com.pms.dto.RepairPageQueryDTO;
import com.pms.dto.RepairUpdateDTO;
import com.pms.entity.Repair;
import com.pms.vo.RepairPageQueryVO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface RepairMapper {
    /**
     * 新增报修
     * @param repair
     */
    @Insert("insert into repair(community_id, building_id, description, status_id, create_date, image)" +
            "values(#{communityId},#{buildingId},#{description},#{statusId},#{createDate},#{image})")
    void save(Repair repair);

    /**
     * 报修分页查询
     * @param repairPageQueryDTO
     * @return
     */
    Page<RepairPageQueryVO> page(RepairPageQueryDTO repairPageQueryDTO);

    /**
     * 批量删除
     * @param id
     */
    @Delete("delete from repair where id=#{id}")
    void delete(Integer id);

    /**
     * 修改报修状态
     * @param repairUpdateDTO
     * @return
     */
    @Update("update repair set status_id=#{statusId} where id=#{id}")
    void update(RepairUpdateDTO repairUpdateDTO);

    /**
     * 根据id查询报修信息
     * @param id
     * @return
     */
    @Select("select * from repair where id=#{id}")
    Repair getById(Integer id);
}
